package thinkingJava.chapter19;

import static util.Print.*;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Set;
import java.util.TreeSet;

import thinkingJava.chapter18.OSExcute;

enum  Explore {
	HERE, THERE
}

public class Reflection {
	public static Set<String> analyze(Class<?> enumClass) {
		print("Analyzing " + enumClass);
		print("interfaces : ");
		for (Type t : enumClass.getGenericInterfaces()) {
			print(t);
		}
		print("Base : " + enumClass.getSuperclass());
		print("Methods : ");
		Set<String> methods = new TreeSet<String>();
		for (Method m : enumClass.getMethods()) {
			methods.add(m.getName());
		}
		print(methods);
		return methods;
	}
	public static void main(String[] args) {
		Set<String> exploreMethods = analyze(Explore.class);
		Set<String> enumMethods = analyze(Enum.class);
		print("exploreMethods.containsAll(enumMethods) ? " + exploreMethods.containsAll(enumMethods));
		print("Explore.removeAll(Enum) : ");
		exploreMethods.removeAll(enumMethods);
		print(exploreMethods);
		OSExcute.command("javap Explore");
	}
}
